<?php ob_start();
session_start();?>
<!DOCTYPE html>
<html>
<head>
<title>Standings</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="Content/site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/bootstrap-datepicker.js"></script>
</head>
<body>
<div class="container blue_border">
<?php  include_once("php/standings_classes.php");
include_once("php/banner.php");
include_once("php/nav_bar.php"); ?>
  <h1>standings</h1>
  <div class="row">
    <div>
      <ul class="nav nav-tabs" id="myTab">
        <li class="active"><a href="#Platinum" data-toggle="tab">Platinum</a></li>
        <li><a href="#Gold" data-toggle="tab">Gold</a></li>
        <li><a href="#Silver" data-toggle="tab">Silver</a></li>
        <li><a href="#Bronse" data-toggle="tab">Bronze</a></li>
      </ul>
      <div class="tab-content">
        <div class="tab-pane active" id="Platinum">
          <div class="row"> 
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <div class="row  text-center">
                <h2>Results after round <?php echo $round_last->round_number." (".$round_last->round_date.")"; ?>
                
                </h2>
              </div>
              <table class="table table-striped table-bordered small-padding">
               <thead>
                  <tr>
                   <th rowspan="2" class="align-middle">Team <br/>Position</th>
                    <th rowspan="2" class="align-middle">Team Name</th>
                    <th colspan="2" class="align-middle">Rounds</th>
                    <th colspan="2" class="align-middle">Matches</th>
                    <th colspan="2" class="align-middle">Games</th>
                  </tr>
                  <tr>
                  	
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
				  $divisionID=1;
				  $result = $repCalc->standinsTeam($divisionID,$firstRoundID,$lastRoundID );
				  $i=1;
				  foreach ($result as $r){
				  ?>
                  <tr>
                    <td> <?php echo $i; $i=$i+1;?> </td>
                    <td> <?php echo $r['team']->team_name; ?> </td>
                    <td> <?php echo $r['roundsWon']; ?></td>
                    <td> <?php echo $r['roundsLost']; ?> </td>
                    <td> <?php echo $r['totalWinMatches']; ?> </td>
                    <td> <?php echo $r['totalLostMatches']; ?> </td>
                    <td> <?php echo $r['totalgameWin']; ?>  </td>
                    <td> <?php echo $r['totalgameLost']; ?> </td>
                  </tr>
                  <?php }?>
                  
                </tbody>
              </table>
            </div>
          </div>
          <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
            <?php $overallStandings=$repCalc->standinsPlayer(1,$firstRoundID, $lastRoundID); ?>
              <table class="table table-striped table-bordered">
                <thead>
                  <tr>
                  	<th>Rank</th>
                    <th>Name</th>
                    <th>Team</th>
                    <th>Win</th>
                    <th>Loss</th>
                  </tr>
                </thead>
                <tbody>
               	  <?php foreach($overallStandings as $s){ 
				  $player = $repPlayer->map($repPlayer->readPlayer($s['playerID']));
				  
				  ?>
                  <tr>
                  	<td><?php echo $s['Rank']; ?></td>
                    <td><?php echo $player->fname. " ".$player->sname; ?></td>
                    <td> <?php if ($s['TeamID']==0){
						echo 'Fill-in';}
					else{
							$team = $repTeam->map($repTeam->readTeam($s['TeamID'])); echo $team->team_name;} ?> </td>
                    <td> <?php echo $s['Won']; ?> </td>
                    <td> <?php echo  $s['Lost']; ?> </td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="tab-pane" id="Gold">
          <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <div class="row  text-center">
                <h2>Results after round <?php echo $round_last->round_number." (".$round_last->round_date.")"; ?>
                
                </h2>
              </div>
              <table class="table table-striped table-bordered small-padding">
                 <thead>
                  <tr>
                   <th rowspan="2" class="align-middle">Team <br/>Position</th>
                    <th rowspan="2" class="align-middle">Team Name</th>
                    <th colspan="2" class="align-middle">Rounds</th>
                    <th colspan="2" class="align-middle">Matches</th>
                    <th colspan="2" class="align-middle">Games</th>
                  </tr>
                  <tr>
                  	
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
				  $divisionID=2;
				  $result = $repCalc->standinsTeam($divisionID,$firstRoundID,$lastRoundID );
				  $i=1;
				  foreach ($result as $r){
				 
				  ?>
                  <tr>
                    <td> <?php echo $i; $i=$i+1;?> </td>
                    <td> <?php echo $r['team']->team_name; ?> </td>
                    <td><?php echo $r['roundsWon']; ?></td>
                    <td><?php echo $r['roundsLost']; ?> </td>
                    <td> <?php echo $r['totalWinMatches']; ?> </td>
                    <td> <?php echo $r['totalLostMatches']; ?> </td>
                    <td> <?php echo $r['totalgameWin']; ?>  </td>
                    <td> <?php echo $r['totalgameLost']; ?> </td>
                  </tr>
                  <?php }?>
                  
                </tbody>
              </table>
            </div>
          </div>
          <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <table class="table table-striped table-bordered">
                <thead>
                  <tr>
                  	<th>Rank</th>
                    <th>Name</th>
                    <th>Team</th>
                    <th>Win</th>
                    <th>Loss</th>
                  </tr>
                </thead>
                <tbody>
                 <?php $overallStandings=$repCalc->standinsPlayer(2,$firstRoundID, $lastRoundID); ?>
               	  <?php foreach($overallStandings as $s){ 
				  $player = $repPlayer->map($repPlayer->readPlayer($s['playerID']));
				  ?>
                  <tr>
                  	<td><?php echo $s['Rank']; ?></td>
                    <td><?php echo $player->fname. " ".$player->sname; ?></td>
                    <td> <?php if ($s['TeamID']==0){
						echo 'Fill-in';}
					else{
							$team = $repTeam->map($repTeam->readTeam($s['TeamID'])); echo $team->team_name;} ?> </td>
                    <td> <?php echo $s['Won']; ?> </td>
                    <td> <?php echo  $s['Lost']; ?> </td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="tab-pane" id="Silver">
        <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <div class="row  text-center">
                <h2>Results after round <?php echo $round_last->round_number." (".$round_last->round_date.")"; ?>
                
                </h2>
              </div>
              <table class="table table-striped table-bordered small-padding">
                <thead>
                  <tr>
                   <th rowspan="2" class="align-middle">Team <br/> Position</th>
                    <th rowspan="2" class="align-middle">Team Name</th>
                    <th colspan="2" class="align-middle">Rounds</th>
                    <th colspan="2" class="align-middle">Matches</th>
                    <th colspan="2" class="align-middle">Games</th>
                  </tr>
                  <tr>
                  	
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
				  $divisionID=3;
				  $result = $repCalc->standinsTeam($divisionID,$firstRoundID,$lastRoundID );
				  $i=1;
				  foreach ($result as $r){
				 
				  ?>
                  <tr>
                    <td> <?php echo $i; $i=$i+1;?> </td>
                    <td> <?php echo $r['team']->team_name; ?> </td>
                    <td><?php echo $r['roundsWon']; ?></td>
                    <td><?php echo $r['roundsLost']; ?> </td>
                    <td> <?php echo $r['totalWinMatches']; ?> </td>
                    <td> <?php echo $r['totalLostMatches']; ?> </td>
                    <td> <?php echo $r['totalgameWin']; ?>  </td>
                    <td> <?php echo $r['totalgameLost']; ?> </td>
                  </tr>
                  <?php }?>
                  
                </tbody>
              </table>
            </div>
          </div>
          <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <table class="table table-striped table-bordered">
                <thead>
                  <tr>
                  	<th>Rank</th>
                    <th>Name</th>
                    <th>Team</th>
                    <th>Win</th>
                    <th>Loss</th>
                  </tr>
                </thead>
                <tbody>
                 <?php  $overallStandings=$repCalc->standinsPlayer(3,$firstRoundID, $lastRoundID); ?>
               	  <?php foreach($overallStandings as $s){ 
				  $player = $repPlayer->map($repPlayer->readPlayer($s['playerID']));
				  
				  ?>
                  <tr>
                  	<td><?php echo $s['Rank']; ?></td>
                    <td><?php echo $player->fname. " ".$player->sname; ?></td>
                    <td> <?php if ($s['TeamID']==0){
						echo 'Fill-in';}
					else{
							$team = $repTeam->map($repTeam->readTeam($s['TeamID'])); echo $team->team_name;} ?> </td>
                    <td> <?php echo $s['Won']; ?> </td>
                    <td> <?php echo  $s['Lost']; ?> </td>
                  </tr>
                  <?php } ?>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div class="tab-pane" id="Bronse">
       <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <div class="row  text-center">
                <h2>Results after round <?php echo $round_last->round_number." (".$round_last->round_date.")"; ?>
                
                </h2>
              </div>
              <table class="table table-striped table-bordered small-padding">
                 <thead>
                  <tr>
                   <th rowspan="2" class="align-middle">Team <br/>Position</th>
                    <th rowspan="2" class="align-middle">Team Name</th>
                    <th colspan="2" class="align-middle">Rounds</th>
                    <th colspan="2" class="align-middle">Matches</th>
                    <th colspan="2" class="align-middle">Games</th>
                  </tr>
                  <tr>
                  	
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                    <th> Won </th>
                    <th> Lost </th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
				  $divisionID=4;
				  $result = $repCalc->standinsTeam($divisionID,$firstRoundID,$lastRoundID );
				  $i=1;
				  foreach ($result as $r){
				 
				  ?>
                  <tr>
                    <td> <?php echo $i; $i=$i+1;?> </td>
                    <td> <?php echo $r['team']->team_name; ?> </td>
                    <td><?php echo $r['roundsWon']; ?></td>
                    <td><?php echo $r['roundsLost']; ?> </td>
                    <td> <?php echo $r['totalWinMatches']; ?> </td>
                    <td> <?php echo $r['totalLostMatches']; ?> </td>
                    <td> <?php echo $r['totalgameWin']; ?>  </td>
                    <td> <?php echo $r['totalgameLost']; ?> </td>
                  </tr>
                  <?php }?>
                  
                </tbody>
              </table>
            </div>
          </div>
          <div class="row">
            <div class="col-xs-12 col-md-8 col-md-offset-2">
              <table class="table table-striped table-bordered">
                <thead>
                  <tr>
                  	<th>Rank</th>
                    <th>Name</th>
                    <th>Team</th>
                    <th>Win</th>
                    <th>Loss</th>
                  </tr>
                </thead>
                <tbody>
                 <?php $overallStandings=$repCalc->standinsPlayer(4,$firstRoundID, $lastRoundID); ?>
               	  <?php foreach($overallStandings as $s){ 
				  $player = $repPlayer->map($repPlayer->readPlayer($s['playerID']));
				  
				  ?>
                  <tr>
                  	<td><?php echo $s['Rank']; ?></td>
                    <td><?php echo $player->fname. " ".$player->sname; ?></td>
                    <td> <?php if ($s['TeamID']==0){
						echo 'Fill-in';}
					else{
							$team = $repTeam->map($repTeam->readTeam($s['TeamID'])); echo $team->team_name;} ?> </td>
                    <td> <?php echo $s['Won']; ?> </td>
                    <td> <?php echo  $s['Lost']; ?> </td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
            </div>
          </div>
       </div>
      </div>
    </div>
  </div>
    <?php 
include_once("php/footer.php");
?>
</div>

</div>
<?php ob_flush();?>
</body>
</html>
